#ifndef MAINDIALOG_H
#define MAINDIALOG_H

#include <QDialog>
#include <QUrl>
#include <QCamera>
#include <QCameraImageCapture>
#include <QMediaRecorder>
#include <QTimer>

#include <QxtSmtp>

class QCameraImageProcessing;
namespace Ui {
class MainDialog;
}

class MainDialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit MainDialog(QWidget *parent = 0);
    ~MainDialog();
    bool hasPassword();

public slots:
    void initPaths();
    bool settingsSaved();
    void resetDefaultSettings();
    void actionSnapImage();
    void stopVideoRecording();
    void stopAutoSnapping();
    void recordVideo();
    void autoSnapImage();
    void chooseSnapImagePath();
    void chooseRecordVideoPath();
    void chooseAutoSnapImagePath();
    void actionSaveSettings();
    void actionTestSendingEmail();
    void setContrast(int value);
    void setDenoisingLevel(int level);
    void setManualWhiteBalance(int colorTemperature);
    void setSaturation(int value);
    void setSharpeningLevel(int level);
    //void setWhiteBalanceMode(WhiteBalanceMode mode);

private slots:
    void _autoSnapImage();
    void authenticationFailed(const QByteArray & msg);
    void connectionFailed(const QByteArray & msg);
    void mailSent(int mailID);
    void mailFailed(int mailID, int errorCode, const QByteArray & msg);


private:
    Ui::MainDialog *ui;
    QCameraImageProcessing *imageProcessing;
    QxtSmtp smtp;
    QCamera camera;
    QCameraImageCapture *imageCapture;
    QMediaRecorder *mediaRecorder;
    void _connectSlots();
    void _initCameraList();
    QString _snapImage(QString imagePath);
    QTimer timer;
};

#endif // MAINDIALOG_H
